package homework.gui;

import com.lovo.netCRM.component.*;
import com.sun.corba.se.spi.ior.ObjectKey;
import homework.bean.ClassBean;
import homework.bean.StudentBean;
import homework.util.DataUtil;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.ImageObserver;
import java.util.List;

public class showStudentInfoDialog extends JDialog {
      //文本输入框
      private LovoLabel  lovoLabel8,lovoLabel1,lovoLabel2,lovoLabel3,lovoLabel4,lovoLabel5,lovoLabel6,lovoLabel7;
    //确定按钮
    private LovoButton  okBtn;

    private StudentFrame studentFrame;

    private LovoLabel lovoLabel;
     private int id;

    public showStudentInfoDialog(StudentFrame studentFrame,Integer studentId){
        this.id = studentId;

        this.studentFrame = studentFrame;

        this.setSize(600,400);
        this.setLayout(null);

        //根据编号查询对应的学生
        StudentBean studentBean = DataUtil.getStudentById(studentId);

        lovoLabel1 = new LovoLabel("姓名","",40,100,this);
        lovoLabel2 = new LovoLabel(studentBean.getName(),"",100,100,this);
        lovoLabel3= new LovoLabel("年龄","",40,150,this);
        lovoLabel4 = new LovoLabel(studentBean.getAge()+"","",100,150,this);
        lovoLabel5 = new LovoLabel("性别","",40,200,this);
        lovoLabel6 = new LovoLabel(studentBean.getGender(),"",100,200,this);
        lovoLabel7 = new LovoLabel("所在班级","",40,250,this);
        lovoLabel8 = new LovoLabel(studentBean.getClassBean().getName(),"",100,250,this);

        lovoLabel = new LovoLabel("头像","显示图片",150,200,this);
//        lovoLabel.setBounds(150, 200, 100, 300);
//        lovoLabel.setIcon( new ImageIcon(studentBean.getPicture()));

         okBtn =  new LovoButton("确定",40,300,this);
          okBtn.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                  showStudentInfoDialog.this.dispose();
              }
          });

        this.setLocationRelativeTo(null);
        this.setVisible(true);



    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        String s = DataUtil.getStudentById(this.id).getPicture();
        g.drawImage(new ImageIcon(s).getImage(), 200, 150,
                120, 200, null);
    }
}
